package com.ch06.service.impl;

import com.ch06.mapper.UserMapper;
import com.ch06.service.UserService;
import jdk.jfr.Name;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author Kx
 * @Date 2025/4/29 8:56
 * @Version 1.0
 */
@Service("userService")
public class UserServiceImpl implements UserService {

    /**
     * JSR250的@Resource注解支持标注在字段和set方法上,name属性用于指定需要注入某个bean的id
     *
     *
     * JSR330的@Inject注解支持标注在字段、构造方法、set方法上,当有多个实现类的时候结合@Named注解来标识需要注入的实现类
    */
//    @Resource(name="userMapper")
    /*@Inject
    @Named("userMapper")*/
    private UserMapper userMapper;

    @Inject
    @Named("userMapper")
    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    //    @Resource(name="userMapper")
    /*@Inject
    @Named("userMapper")*/
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public void save() {
        userMapper.add();
    }
}
